//----------------------- Output Registers, physical pins
#define PORT_BBA15 PORTF, PF0
#define PORT_BBA16 PORTF, PF1
#define PORT_AWE PORTF, PF2
#define PORT_AOE PORTF, PF3
#define PORT_ACE PORTF, PF4
#define PORT_ABOE PORTE, PE2
#define PORT_AACOE PORTB, PB0
#define PORT_AACCLR PORTB, PB2
#define PORT_AACUP PORTB, PB3
#define PORT_CMDOE PORTB, PB5
#define PORT_CMDOD PORTG, PG3
#define PORT_CMDEV PORTG, PG0
#define PORT_OED PORTD, PD7
#define PORT_ARP PORTD, PD4
#define PORT_BU1 PORTA
#define PORT_BU2 PORTC
#define PORT_AUX1 PORTE, PE3
#define PORT_AUX2 PORTB, PB4
#define PORT_AUX3 PORTB, PB7
#define PORT_AUX4 PORTG, PG2

//----------------------- Data Direction Registers
#define DDR_BBA15 DDRF, PF0
#define DDR_BBA16 DDRF, PF1
#define DDR_AWE DDRF, PF2
#define DDR_AOE DDRF, PF3
#define DDR_ACE DDRF, PF4
#define DDR_ABOE DDRE, PE2
#define DDR_AACOE DDRB, PB0
#define DDR_AACCLR DDRB, PB2
#define DDR_AACUP DDRB, PB3
#define DDR_CMDOE DDRB, PB5
#define DDR_CMDOD DDRG, PG3
#define DDR_CMDEV DDRG, PG0
#define DDR_OED DDRD, PD7
#define DDR_ARP DDRD, PD4
#define DDR_BU1 DDRA
#define DDR_BU2 DDRC
#define DDR_AUX1 DDRE, PE3
#define DDR_AUX2 DDRB, PB4
#define DDR_AUX3 DDRB, PB7
#define DDR_AUX4 DDRG, PG2
#define DDR_XCK DDRD, PD5

//----------------------- Input Registers
#define PIN_BU1 PINA
#define PIN_BU2 PINC
#define PIN_ARB PIND, PD5
#define PIN_USRSW1 PINE, PE4
#define PIN_USRSW2 PINE, PE5
#define PIN_USRSW3 PINE, PE6
#define PIN_USRSW4 PIND, PD1
#define PIN_USRSW5 PIND, PD0
#define PIN_IGNINT PINE, PE7
#define INT_IGN			eINT7

//---------------------- Output Definitions
#define AUX_OUT_12_SET_PWM(x)	timer_initialise_mode(3,x,TIMER_PWMFC)
#define AUX_OUT_1_TIMER			3
#define AUX_OUT_1_SET(x)		timer_3_pwm_A_set(x)
#define AUX_OUT_1_SET_VALUE(x)	timer_3_pwm_A_set_value(x)
#define AUX_OUT_1_STATUS		timer_status(3)
//#define AUX_OUT_2_SET
//#define AUX_OUT_2_SET_VALUE
//#define AUX_OUT_2_STATUS
#define AUX_OUT_34_SET_PWM(x)	timer_initialise_mode(1,x,TIMER_PWMFC)
#define AUX_OUT_3_TIMER			1
#define TMR_OVER				eTimer1_Overflow
#define AUX_OUT_3_SET(x)		timer_1_pwm_C_set(x)
#define AUX_OUT_3_SET_VALUE(x)	timer_1_pwm_C_set_value(x)
#define AUX_OUT_3_STATUS		timer_status(1)
//#define AUX_OUT_4_SET
//#define AUX_OUT_4_SET_VALUE
//#define AUX_OUT_4_STATUS

//#define AUX_OUT_5_SET_PWM(x)
#define AUX_OUT_5_SET(x)		timer_1_pwm_B_set(x)
#define AUX_OUT_5_SET_VALUE(x)	timer_1_pwm_B_set_value(x)
#define AUX_OUT_5_STATUS		timer_status(1)
// Flash Memory Restrictions
#define FLASH_END		0x3FFFF

#define ADC_MAX				5120
#define ADC_MULT			12.7875
#ifndef ADC_INITIAL_REF
#define ADC_INITIAL_REF AVCC

#define THREAD_TIMER	eTimer2_Compare
#define THREAD_TIMER_NO	2

#endif
